<template>
	<view class="">
		<uv-form-item v-if="type=='vip'" :label="item.fieldLabel" prop="name" borderBottom>
			<uv-input @blur="blur" :type="item.fieldType.type" :placeholder="`请输入${item.fieldLabel}`"
				v-model="data.values" border="none">
			</uv-input>
		</uv-form-item>
		<uv-form-item v-else :required="item.isRequired" :label="item.fieldLabel">
			<uv-input @blur="blur" :type="item.fieldType.type" v-model="data.value"
				:placeholder="`请输入您的${item.fieldLabel}`">
			</uv-input>
		</uv-form-item>
	</view>
</template>

<script setup>
	import {
		defineProps,
		ref,
		defineEmits,
		onMounted,
		watch
	} from 'vue';
	const props = defineProps(['item', 'index', 'id', 'type']);
	const emit = defineEmits(['resValue']);
	const data = ref({
		value: ''
	})
	onMounted(() => {
		if (props.id) {

			data.value.value = props.item.resValue;
		}


	})
	// watch(props.item, (newVal, oldVal) => {
	// 		if (props.id) {
	// 			let item = newVal;
	// 			console.log(item)
	// 			console.log(item.fieldLabel)
	// 			console.log(item.resValue)
	// 			data.value.value = item.resValue;
	// 		})
	// }

	const blur = () => {
		emit('resValue', {
			index: props.index,
			value: data.value.value
		})
	};
</script>

<style>
</style>